// Contains all the methods required for povray to interface with the optimisations
#ifndef OPTIMISATIONS_H
#define OPTIMISATIONS_H

#include <windows.h>
//#include "vicon.h"
//#include "poisson.h"
// variables required for panel drawing originaly in pvengine.cpp
// Bitmap header info with palette included
typedef struct
{
  BITMAPINFOHEADER      header ;
  RGBQUAD               colors [256] ;
} BitmapInfo ;
extern double maxclrbackup; // GLOBAL VARIABLE
extern HWND                    render_window ;
extern HPALETTE                hPalApp ;
extern int                     render_bitmap_depth;
extern long                    render_bitmap_bpl ;
typedef unsigned char   uchar;
extern uchar                   *render_bitmap_surface ;
extern uchar                   *render_priority_surface ;
extern uchar				   *opt5copy_bitmap;
extern BitmapInfo              render_bitmap ;
extern BitmapInfo              bitmap_template ;
extern HINSTANCE               hInstance ;
extern unsigned                render_width ;
extern unsigned                render_height ;
extern int                     renderwin_xoffset ;
extern int                     renderwin_yoffset ;

void toggleScreen();
bool getScreen();
void dropScreen();
bool getWorking();

//information required in drawing routine
enum TraceType {
      trace,
      silent,
      none,
   };
struct Coordinate{

	Coordinate():x(0.0),y(0.0),z(0.0){}

	double x;
	double y;
	double z;
};
struct PixelRender {
	PixelRender(): trace(TraceType::none),x(0),y(0),area(0){}
	TraceType trace;
	int x;
	int y;
	int area;
};
struct Coord2D{

	Coord2D():x(0),y(0){}
	int x;
	int y;
};

bool setupOptimisations();
bool resetFrame();

//the maximum size picture allowed
const int maxsize = 2501;
PixelRender getPixel(int,int);
int getArea();
int getAvgTime();

//compare image
void requiredSize(int x);
void grabImage();
void setCompare(bool x);
bool getCompare();
int getCompareValue();
void updateRegion(int x, int y, int atra);
void priorityImage(int x1, int y1, int area, int delay);

//blur
bool interpolate(int x1, int y1, int area, int red, int green, int blue, int alpha);

//edge detection
void setToleranceValUp();
void setToleranceValDown();
int getTolerance();

//void setDirection(double x, double y, double z);
int getDelay(int x,int y, int area);
Coordinate getDirection();
void setSky(double x, double y, double z);
void setUp(double x, double y, double z);
Coordinate getUp();
void setRight(double x, double y, double z);
Coordinate getRight();
void setDirection(double x, double y, double z);
void setAngle(double x);
double getAngle();
Coordinate getViewpoint();
Coordinate getDrawViewpoint();
void setView(double x, double y, double z);
bool getViewChange();
bool getViewRefresh();
void newViewX(int val, int limit);
void newViewY(int val, int limit);
void newViewZ(int val, int limit);
void setFocus(double x, double y, double z);
void viewUpdate();
Coordinate getFocus();
void updateVar();

//optimisation
bool getOptimsation1();
bool getOptimsation2();
bool getOptimsation3();
bool getOptimsation4();
bool getOptimsation5();
void setOptimsation1(bool);
void setOptimsation2(bool);
void setOptimsation3(bool);
void setOptimsation4(bool);
void setOptimsation5(bool);

// vicom controls
void setupVicon();
bool getVicon();
void setVicon(bool);

#endif